package com.siki.vo;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.util.BeanUtil;
import com.siki.pojo.model.DepartmentInformation;
import com.siki.pojo.model.User;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
 * @Author Siki
 * @Date 2020/4/26
 */
@ApiModel("部门信息VO")
@Getter
@Setter
@NoArgsConstructor
public class UserIntentionVO {
    @ApiModelProperty("id")
    Long id;

    @ApiModelProperty("次序")
    Integer no;

    @ApiModelProperty("意愿部门名称")
    String departmentInfo;

    @ApiModelProperty("意愿部门名称")
    String post;

    @ApiModelProperty("部门审核状态")
    String resultType;

    @ApiModelProperty("平均得分")
    Integer score;

    @ApiModelProperty("总体评价")
    String remark;

    public UserIntentionVO(DepartmentInformation departmentInformation){
        Optional.ofNullable(departmentInformation).ifPresent(departmentInformations ->{
            this.id=departmentInformations.getId();
            this.no = departmentInformations.getNo();
            this.departmentInfo = departmentInformations.getDepartmentInfo();
            this.post = departmentInformations.getPost();
            this.resultType = departmentInformations.getResultType().toString();
            this.score = departmentInformations.getScore();
            this.remark = departmentInformations.getRemark();
        } );
    }

    public static List<UserIntentionVO> getList(List<DepartmentInformation> departmentInformations){
        List<UserIntentionVO> userIntentionVOS = new ArrayList<>();
        for (DepartmentInformation di :
                departmentInformations) {
            userIntentionVOS.add(new UserIntentionVO(di));
        }
        return userIntentionVOS;
    }
}
